home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / Papers / From CodeWarrior to Delphi / Mac⁄Win⁄DLL / Calcs.p < prev    next >
Encoding:
Text File  |  1997-11-12  |  1.7 KB  |  107 lines  |  [TEXT/CWIE]

  1. UNIT Calcs;
  2.  
  3. INTERFACE
  4.  
  5. type
  6.     ShortString = string[255];
  7.     StrPtr = ^ShortString;
  8.  
  9. {For DLLs, use CodeWarrior's default calling convention,}
  10. {which matches Delphi's "pascal" convention}
  11.  
  12. function AddShort(i,j:integer): integer;
  13. {$IFC DLLTARGET}
  14.     DLLEXPORT;
  15. {$ENDC}
  16.  
  17. function AddLong(i,j:longint): longint;
  18. {$IFC DLLTARGET}
  19.     DLLEXPORT;
  20. {$ENDC}
  21.  
  22. function AddSingle(i,j:real): real;
  23. {$IFC DLLTARGET}
  24.     DLLEXPORT;
  25. {$ENDC}
  26.  
  27. function AddDouble(i,j:double): double;
  28. {$IFC DLLTARGET}
  29.     DLLEXPORT;
  30. {$ENDC}
  31.  
  32. procedure Add3Doubles(a,b,c:double; var total:double);
  33. {$IFC DLLTARGET}
  34.     DLLEXPORT;
  35. {$ENDC}
  36.  
  37. function XAdd3Doubles(a,b,c:double; var total:double): longint;
  38. {$IFC DLLTARGET}
  39.     DLLEXPORT;
  40. {$ENDC}
  41.  
  42. procedure GetTextFromDLL1(p:StrPtr; var S,L:longint);
  43. {$IFC DLLTARGET}
  44.     DLLEXPORT;
  45. {$ENDC}
  46.  
  47. procedure GetTextFromDLL2(var sss:ShortString; var S,L:longint);
  48. {$IFC DLLTARGET}
  49.     DLLEXPORT;
  50. {$ENDC}
  51.  
  52.  
  53. {=======================================================================}
  54.  
  55. IMPLEMENTATION
  56.  
  57. function AddShort(i,j:integer): integer;
  58. begin
  59.     AddShort := i + j;
  60. end;
  61.  
  62. function AddLong(i,j:longint): longint;
  63. begin
  64.     AddLong := i + j;
  65. end;
  66.  
  67.  
  68. function AddSingle(i,j:real): real;
  69. begin
  70.     AddSingle := i + j;
  71. end;
  72.  
  73.  
  74. function AddDouble(i,j:double): double;
  75. begin
  76.     AddDouble := i + j;
  77. end;
  78.  
  79.  
  80. function XAdd3Doubles(a,b,c:double; var total:double): longint;
  81. begin
  82.     total := a + b + c;
  83.     XAdd3Doubles := 0;
  84. end;
  85.  
  86. procedure Add3Doubles(a,b,c:double; var total:double);
  87. begin
  88.     total := a + b + c;
  89. end;
  90.  
  91. procedure GetTextFromDLL1(p:StrPtr; var S,L:longint);
  92. begin
  93.     p^[2] := '@';
  94.     S := LENGTH(p^);
  95. end;
  96.  
  97.  
  98. procedure GetTextFromDLL2(var sss:ShortString; var S,L:longint);
  99. begin
  100.     sss[2] := '@';
  101.     S := LENGTH(sss);
  102. end;
  103.  
  104.  
  105.  
  106. END.
  107.